//
//  CYUserHeader.m
//  CaiYun
//
//  Created by 今日信息科技 on 2017/6/29.
//  Copyright © 2017年 今日信息科技. All rights reserved.
//

#import "CYUserHeader.h"

@implementation CYUserHeader
/*我的页面 tableview的header*/
+ (NSArray *)getHeader:(NSArray *)array{
    
    NSMutableArray *mutableArr = [NSMutableArray array];
    CYView *view = [[CYView alloc]initWithColor:[UIColor whiteColor]];
    
    //
    for (int i = 0; i < array.count; i ++) {
        CYButton  *button = [[CYButton alloc]initWithTitle:array[i][@"title"] titlesize:18 cornerRadius:0.0];
        button.tag = 200 + i;
        [button setImage:[UIImage imageNamed:array[i][@"img"]] forState:UIControlStateNormal];
        button.imageEdgeInsets = UIEdgeInsetsMake(0.0, -5, 0.0, 0.0);
        button.titleEdgeInsets = UIEdgeInsetsMake(0.0, 0.0, 0.0, -5);
        [button addTarget:nil action:@selector(rechargeOrDrawCash:) forControlEvents:UIControlEventTouchUpInside];
        [view addSubview:button];
        
        [button mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(view).with.offset(SCREEN_WIDTH / 2.0 * i);
            make.centerY.equalTo(view);
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH / 2.0, AUTO(PT(120))));
        }];
        
        CYView * lineView = [self lightgrayView];
        [view addSubview:lineView];
        
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(lineView.bounds.size);
            make.centerX.equalTo(view);
            if (i == 0)
                make.top.equalTo(view).with.offset(0);
            else if (i == 1)
                make.bottom.equalTo(view.mas_bottom).with.offset(0);
        }];
    }
    CYView *midLine = [[CYView alloc]initWithColor:[UIColor lightGrayColor]];
    [view addSubview:midLine];
    
    [midLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_offset(UIEdgeInsetsMake(20, SCREEN_WIDTH / 2.0 - 0.25, 20, SCREEN_WIDTH / 2.0 - 0.25));
    }];
    [mutableArr addObject:@{@"headerView":view,@"headerHeight":@(AUTO(PT(120)))}];
    
    
    //
    for (int i = 0 ; i < 2; i ++) {
        
        [mutableArr addObject:@{@"headerView":[self lightgrayView],@"headerHeight":@(5)}];
    }
    
    return (NSArray *)mutableArr;
}

+ (CYView *)lightgrayView{
    
    CYView *view = [[CYView alloc]initWithColor:RGBA(245, 246, 250, 1)];
    view.bounds = CGRectMake(0.0, 0.0, SCREEN_WIDTH, 5);
    return view;
}
/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end
